//
//  GJFCollectionViewCell.m
//  Wedding
//
//  Created by 郭静芬 on 2016/12/21.
//  Copyright © 2016年 郭静芬. All rights reserved.
//

#import "GJFCollectionTableViewCell.h"

#define XXX [UIScreen mainScreen].bounds.size.width / 375
#define YYY [UIScreen mainScreen].bounds.size.height / 667

@interface GJFCollectionTableViewCell ()
@property (nonatomic, strong) UIImageView *imageV;
@property (nonatomic, strong) UILabel *title;
@end

@implementation GJFCollectionTableViewCell

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self imageV];
        [self title];
    }
    return self;
}
#pragma mark - Model的setter方法
- (void)setClassifyModel:(GJFClassifyModel *)classifyModel {
    _classifyModel = classifyModel;
    self.imageV.image = [UIImage imageNamed:classifyModel.imageName];
    self.title.text = classifyModel.title;
}
- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes {
    [super applyLayoutAttributes:layoutAttributes];
    self.imageV.frame = CGRectMake(15 * XXX, 8 * YYY, self.contentView.frame.size.width - 30 * YYY, self.contentView.frame.size.height - 30 * YYY);
    self.title.frame = CGRectMake(0, self.imageV.frame.size.height + 10 * YYY, self.contentView.frame.size.width, 25 * YYY);
}
#pragma mark - 懒加载
- (UIImageView *)imageV {
    if (!_imageV) {
        _imageV = [[UIImageView alloc] init];
        _imageV.layer.cornerRadius = 20 * YYY;
        _imageV.clipsToBounds = YES;
        [self.contentView addSubview:_imageV];
    }
    return _imageV;
}
- (UILabel *)title {
    if (!_title) {
        _title = [[UILabel alloc] init];
        _title.textAlignment = NSTextAlignmentCenter;
        _title.font = [UIFont systemFontOfSize:14 * XXX];
        [self.contentView addSubview:_title];
    }
    return _title;
}
@end
